<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .weatcher{
            font-size: 32px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="test"></div>
    <script src="./js/react.development.js" crossorigin></script> 
    <script src="./js/react-dom.development.js" crossorigin></script>
    <script src="./js/babel.min.js"></script>
    <script type="text/babel"> /* 此处一定要写babel */
        class Weather extends React.Component{
            constructor(props){
                super(props)
                this.state = {isHot: false,wind:'微风'}
                // 解决this的指向问题
                this.changeWeather = this.changeWeather.bind(this)
            }
            
            render(){
                console.log(this)
                const { isHot,wind } = this.state
                return (
                    <div onClick={this.changeWeather} className="weatcher">今天天气很{isHot ? '炎热' : '凉爽'},{wind}</div>
                )
            }
            changeWeather () {
                console.log(this.props)
                // this.state.isHot = !this.state.isHot
                this.setState({
                    isHot: !this.state.isHot
                })
            }
        }

        ReactDOM.render(<Weather/>,document.getElementById('test'))

        
    </script>
</body>
</html>